//
//  HisDynamicViewController.m
//  DefendHealth
//
//  Created by 吾诺翰卓003 on 17/2/20.
//  Copyright © 2017年 iMacOne. All rights reserved.
//

#import "HisDynamicViewController.h"
#import "HisDynamicTableViewCell.h"
@interface HisDynamicViewController ()

@end

@implementation HisDynamicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.TitleNav.hidden = YES;
    [self.view addSubview:self.leftbutton];
    self.baseTableView.frame = CGRectMake(0, 0, WindowWidth, WindowHeight);
    [self addHeadView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)addHeadView{
    UIView *headView = [UIView new];
    
    headView.backgroundColor = [UIColor whiteColor];
    
    
    UIImageView *touxiang = [UIImageView new];
    touxiang.frame = CGRectMake((WindowWidth-55)/2, 35, 55, 55);
    touxiang.backgroundColor = [UIColor grayColor];
    touxiang.layer.masksToBounds = YES;
    touxiang.layer.cornerRadius = 27.5;
    [headView addSubview:touxiang];
    
    UILabel *nameLab = [UILabel new];
    nameLab.frame = CGRectMake(0, kMaxY(touxiang.frame)+13, WindowWidth, 19);
    nameLab.text = @"MDK";
    nameLab.font = FONT(19);
    nameLab.textColor = UIColorFromRGB(0x333333);
    nameLab.textAlignment = 1;
    [headView addSubview:nameLab];
    
    UILabel *cityLab1 = [UILabel new];
    cityLab1.frame = CGRectMake(0, kMaxY(nameLab.frame)+10, WindowWidth, 9);
    cityLab1.text = @"浙江杭州 23岁";
    cityLab1.font = FONT(9);
    cityLab1.textColor = UIColorFromRGB(0x666666);
    cityLab1.textAlignment = 1;
    [headView addSubview:cityLab1];
    
    UILabel *contentLab1 = [UILabel new];
    contentLab1.frame = CGRectMake(0, kMaxY(cityLab1.frame)+10, WindowWidth, 10);
    contentLab1.text = @"21521粉丝|255关注";
    contentLab1.font = FONT(10);
    contentLab1.textColor = UIColorFromRGB(0x333333);
    contentLab1.textAlignment = 1;
    [headView addSubview:contentLab1];
    
    UIButton *FocusOnbtn1 = [[UIButton alloc] initWithFrame:CGRectMake((WindowWidth-160-20)/2, kMaxY(contentLab1.frame)+33, 80, 30)];
    [FocusOnbtn1 setTitle:@"关注" forState:UIControlStateNormal];
    [FocusOnbtn1 addTarget:self action:@selector(guanzhu) forControlEvents:UIControlEventTouchUpInside];
    FocusOnbtn1.titleLabel.font = FONT(13);
    FocusOnbtn1.backgroundColor = [UIColor grayColor];
    [FocusOnbtn1 setTitleColor:[UIColor whiteColor] forState:0];
    [headView addSubview:FocusOnbtn1];
    
    UIButton *chatbtn1 = [[UIButton alloc] initWithFrame:CGRectMake(kMaxX(FocusOnbtn1.frame)+20, kMaxY(contentLab1.frame)+33, 80, 30)];
    [chatbtn1 setTitle:@"发起会话" forState:UIControlStateNormal];
    [chatbtn1 addTarget:self action:@selector(guanzhu) forControlEvents:UIControlEventTouchUpInside];
    chatbtn1.titleLabel.font = FONT(13);
    chatbtn1.backgroundColor = [UIColor grayColor];
    [chatbtn1 setTitleColor:[UIColor whiteColor] forState:0];
    [headView addSubview:chatbtn1];
    
    
    NSArray *titleArr = @[@"时间",@"完成",@"消耗"];
    NSArray *contentArr = @[@"120",@"15",@"5142"];
    NSArray *viceTitleArr = @[@"分钟",@"次",@"大卡"];
    for (int i = 0 ; i<titleArr.count; i++) {
        UIView *view1 = [UIView new];
        view1.frame = CGRectMake(WindowWidth/3*i, kMaxY(chatbtn1.frame)+30,WindowWidth/3 , 55);
        view1.backgroundColor = [UIColor whiteColor];
        [headView addSubview:view1];
        
        UILabel *titlelab1 = [UILabel new];
        titlelab1.frame = CGRectMake(0, 0, WindowWidth/3, 10);
        titlelab1.text = titleArr[i];
        titlelab1.font = FONT(10);
        titlelab1.textColor = UIColorFromRGB(0x333333);
        titlelab1.textAlignment = 1;
        [view1 addSubview:titlelab1];
        
        UILabel *contentLab1 = [UILabel new];
        contentLab1.frame = CGRectMake((WindowWidth/3-[ToolUtil autoWidth:contentArr[i] width:500 height:16 num:16]-[ToolUtil autoWidth:viceTitleArr[i] width:500 height:11 num:11])/2, kMaxY(titlelab1.frame)+8, [ToolUtil autoWidth:contentArr[i] width:500 height:16 num:16], 16);
        contentLab1.text = contentArr[i];
        contentLab1.font = FONT(16);
        contentLab1.textColor = UIColorFromRGB(0x333333);
        contentLab1.textAlignment = 0;
        [view1 addSubview:contentLab1];
        
        UILabel *viceLab1 = [UILabel new];
        viceLab1.frame = CGRectMake(kMaxX(contentLab1.frame), kMaxY(titlelab1.frame)+8+5, [ToolUtil autoWidth:viceTitleArr[i] width:500 height:11 num:11], 11);
        viceLab1.text = viceTitleArr[i];
        viceLab1.font = FONT(11);
        viceLab1.textColor = UIColorFromRGB(0x333333);
        viceLab1.textAlignment = 0;
        [view1 addSubview:viceLab1];
    }
    
    UIView *hui = [UIView new];
    hui.frame = CGRectMake(10, kMaxY(chatbtn1.frame)+30+55,WindowWidth-20 , 1.5);
    hui.backgroundColor = kLineColor;
    [headView addSubview:hui];
    
    UILabel *dongtaiLab1 = [UILabel new];
    dongtaiLab1.frame = CGRectMake(10, kMaxY(hui.frame)+19, [ToolUtil autoWidth:@"TA的动态" width:500 height:9 num:9], 9);
    dongtaiLab1.text = @"TA的动态";
    dongtaiLab1.font = FONT(9);
    dongtaiLab1.textColor = UIColorFromRGB(0x333333);
    dongtaiLab1.textAlignment = 0;
    [headView addSubview:dongtaiLab1];
    
    UILabel *dongtaiNumlab1 = [UILabel new];
    dongtaiNumlab1.frame = CGRectMake(kMaxX(dongtaiLab1.frame)+8, kMaxY(hui.frame)+15, 118, 13);
    dongtaiNumlab1.text = @"4";
    dongtaiNumlab1.font = FONT(13);
    dongtaiNumlab1.textColor = UIColorFromRGB(0x333333);
    dongtaiNumlab1.textAlignment = 0;
    [headView addSubview:dongtaiNumlab1];
    
    headView.frame = CGRectMake(0, 0,WindowWidth , kMaxY(dongtaiLab1.frame)+15);
    self.baseTableView.tableHeaderView = headView;
}

#pragma mark - 关注
-(void)guanzhu{
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  162.5+6;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString * cellIden = @"HisDynamicTableViewCell";
    HisDynamicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIden];
    if (cell == nil) {
        cell = [[HisDynamicTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIden];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}

@end
